<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        (function test() {
            console.log("javascript程序运行测试~");
            const arr = [-1, 2, 2, 3, -1];
            let tmpMap = new Map();
            arr.map(item => {
                if (!tmpMap.has(item)) {
                    tmpMap.set(item, 1);
                } else {
                    tmpMap.set(item, tmpMap.get(item) + 1);
                }
            });
            for (const key of tmpMap.keys()) {
                console.log(`数字${key},出现次数${tmpMap.get(key)}`);
            }
        })();
    </script>
</body>

</html>